package com.yt.website.action;

import com.yt.core.MsgBean;
import com.yt.website.api.interfaces.UserInfoService;
import com.yt.website.api.model.UserInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/user")
public class UserAction {
	private Log log = LogFactory.getLog(UserAction.class);
	
	@Autowired
	private UserInfoService userInfoService;


	@RequestMapping("/find")
	public @ResponseBody
	Object findUser(@RequestParam("uid") Long uid) {

		MsgBean msg = new MsgBean();
		try {
			UserInfo userInfo = userInfoService.get(uid);
		} catch (Exception e) {
			e.printStackTrace();
			msg.setFailure(e.getMessage());
		}
		return msg.returnMsg();
	}
	
	/**
	 * 更新密码
	 *
	 * @return
	 */
	@RequestMapping(value="/updatepassword")
	public @ResponseBody
	Object updatePasswd(@RequestParam("old") String oldPass,
			@RequestParam("new") String newPass) {

		MsgBean msg = new MsgBean();

		if (StringUtils.isEmpty(newPass) || newPass.trim().equals("")) {
			// Assert.hasLength(newPass, "新密码不能为空");
			msg.setFailure("密码不能为空哦~");
			return msg.returnMsg();
		}

		if (newPass.length() < 6) {
			msg.setFailure("密码不能少于6位哦~");
			return msg.returnMsg();
		}
		if (newPass.length() > 15) {
			msg.setFailure("密码不能大于15位哦~");
			return msg.returnMsg();
		}
		return  msg.returnMsg();
	}
    
}